<?include dirname(__FILE__).'/../../include/js/row.php' ?>
<h4><?php echo $pageTitle?></h4>
<form action="<?=common::url('row.php?action=' . $formAction . '&table=' . rawurlencode($tableName) . "&rowid=$rowID")?>" method="post" name="rowForm">
<input type="hidden" name="redirect" value="<?=$_GET['redirect']?>" />
<table border="0">
<tr>
	<th><?php echo lang('Field')?></th>
	<th><?php echo lang('Type')?></th>
	<th><?php echo lang('Function')?></th>
	<th><?php echo lang('Null')?></th>
	<th><?php echo lang('Value')?></th>
</tr>
<?foreach($tableStructure as $t):?>
<tr>
	<td><?php echo $t['name']?></td>
	<td><?php echo $t['type']?></td>
	<td>
		<select name="functions[<?php echo $t['name']?>]" <?if($t['autoincrement'] AND $isInsert):?>disabled="disabled" class="disabled"<?endif?> >
            	<option value=""></option>
            	<optgroup label="<?php echo lang('SQLite Functions')?>">
                        <option value="sqlite:abs">ABS</option>
                        <option value="sqlite:date">DATE</option>
                        <option value="sqlite:datetime">DATETIME</option>
                        <option value="sqlite:last_insert_rowid">LAST_INSERT_ROWID</option>
				<option value="sqlite:length">LENGTH</option>
				<option value="sqlite:lower">LOWER</option>
                        <option value="sqlite:random">RANDOM</option>
				<option value="sqlite:round">ROUND</option>
                        <option value="sqlite:soundex">SOUNDEX</option>
				<option value="sqlite:sqlite_version">SQLITE_VERSION</option>
                        <option value="sqlite:upper">UPPER</option>
	            </optgroup>
            	<optgroup label="<?php echo lang('PHP Functions')?>">
	            	<option value="php:md5">MD5</option>
	            </optgroup>
            	<optgroup label="<?php echo lang('User Functions')?>">
<?foreach($userFunctions as $f):?>
            		<option value="sqlite:<?php echo $f['actual']?>"><?php echo strtoupper($f['friendly'])?></option>
<?endforeach?>
	            </optgroup>
		</select>
	</td>
	<td><?php echo ($t['notnull'] ? '' : "<input type=\"checkbox\" value=\"1\" name=\"null[$t[name]]\" onclick=\"nullifyInput(this, '" . javascript::escapeString($t['name']) . "')\"/>")?></td>
	<td><input type="text" value="<?php echo $rowData[$t['name']]?>" name="rowData[<?php echo $t['name']?>]" <?if($t['autoincrement'] AND $isInsert):?>disabled="disabled" class="disabled"<?endif?> /></td>
</tr>
	<?endforeach?>
<tr>
	<td colspan="5" align="right">
		<table border="0">
		<tr>
			<td><input type="radio" name="redirectType" value="return" id="redirectType_return" checked="checked" /><label for="redirectType_return"><?php echo lang('Return to previous page')?></label></td>
		</tr>
    		<tr>
    			<td><input type="radio" name="redirectType" value="insert" id="redirectType_insert" /><label for="redirectType_insert"><?php echo lang('Insert another row')?></label></td>
    		</tr>
		</table>
	</td>
</tr>
<tr>
	<td colspan="5" align="right"><input type="submit" value="<?php echo $submitLabel?>" /></td>
</tr>
</table>
</form>